package tutorial.lite_mod.system_use.error_msg;

import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import public_util.model.Const4PublicDataBase;
import public_util.model.PublicMiddleTable;
import public_util.pack_4_stable.tools.DateTool;
import system_api_4_trade.dao.ApiPublicMiddleTableMapper;
import system_api_4_trade.util.sql.InsertTool;
import system_api_4_trade.util.sql.SelectTool;

import java.util.Date;
import java.util.HashMap;
import java.util.List;


/**
 * public_middle_table_system_use_error_msg
 */
public class Tool4ErrorMsg {

    private static Logger logger = Logger.getLogger(Tool4ErrorMsg.class);
    /**
     * 日志信息的插入
     */
    public static void insert_error_msg_table(SqlSession session , ApiPublicMiddleTableMapper midMapper, String msg_tag_mid_table, String unique_key, HashMap<String, Object> paraPrice)
    {
        paraPrice.put(Const4PublicDataBase.PARA_type_middle_app, 404404404);
        paraPrice.put(Const4PublicDataBase.PARA_type_inner_app, 1001);
        paraPrice.put(Const4PublicDataBase.PARA_is_online, 0);
        paraPrice.put(Const4PublicDataBase.PARA_tag_mid_table, msg_tag_mid_table);//实体的MSG, 放在这里
        paraPrice.put(Const4PublicDataBase.PARA_time_insert, DateTool.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        paraPrice.put(Const4PublicDataBase.PARA_unique_key, unique_key);
        HashMap<String, Object> selMap = InsertTool.paramap2Insert(paraPrice, "public_middle_table_system_use_error_msg");
        midMapper.insertPublicMiddleTable(selMap);
        session.commit();
    }



    /**
     * 插入错误日志信息
     */
    public static List<PublicMiddleTable> show_error_msg_table(SqlSession session , ApiPublicMiddleTableMapper midMapper, String unique_key)
    {
        HashMap<String, Object> paraPrice = new HashMap<String, Object>();
        paraPrice.put(Const4PublicDataBase.PARA_type_middle_app, 404404404);
        paraPrice.put(Const4PublicDataBase.PARA_type_inner_app, 1001);
        paraPrice.put(Const4PublicDataBase.PARA_is_online, 0);
        paraPrice.put(Const4PublicDataBase.PARA_unique_key + "_in", unique_key);
        HashMap<String, Object>  realPara = SelectTool.paramap2selectMap(paraPrice, "public_middle_table_system_use_error_msg");
        List<PublicMiddleTable> listQianyuePrice = midMapper.tableDataList(realPara);//查询是否具备值
        return listQianyuePrice;
    }



}
